<script setup lang="ts">
interface Props {
  length: number
  value: string
}

const { length, value } = defineProps<Props>()
</script>

<template>
  <div class="gird-input" :style="{ '--max-length': length }">
    <div v-for="(item, index) in length" :key="index" class="gird-input-item">
      <div class="gird-input-item-inner">{{ value[index] }}</div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.gird-input {
  display: grid;
  grid-template-columns: repeat(var(--max-length), 1fr);

  .gird-input-item {
    border-radius: 4px;
    border: 1px solid #e6e6e6;
    height: 32px;
    width: 32px;
    line-height: 32px;
    text-align: center;
    font-size: 24px;
    color: #333;

    .gird-input-item-inner {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
